package com.chen.base.utils.basic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: ChenJinLong
 * @DATE: 2024/8/16
 **/
public class MapUtil {

    /**
     * 创建K V键值对的map对象
     * @param key key
     * @param value value
     * @return HashMap
     */
    public static <K, V> Map<K, V> singleMap(K key, V value){
        Map<K, V> map = new HashMap<>(1);
        map.put(key, value);
        return map;
    }

    public static <K, V> K getIndexKey(Map<K, V> map, int index){
        Map.Entry<K, V> kvEntry = new ArrayList<>(map.entrySet()).get(index);
        return kvEntry.getKey();
    }
}
